#include <iostream>
using namespace std;

//string求子串

//string substr(int pos = 0, int n = npos);
//返回由pos开始的n个字符组成的字符串

void test1()
{
    string str = "abcdef";

    string substr = str.substr(1, 3);

    cout << "substr = " << substr << endl;
}

//实用操作
void test2()
{
    string email = "hello@sina.com";

    //从邮件地址中 获取 用户名信息
    int pos = email.find("@");

    string userName = email.substr(0, pos);

    cout << "userName = " << userName << endl;
}

int main()
{
    test1();
    cout << "------------------" << endl;
    test2();
    return 0;
}